Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

343
Views
How to use the NEST ".net client" for Elasticsearch to paginate through all the records?

I am trying to use the C# .net client for Elasticsearch NEST to paginate through all the available records.

I want to get a list of all ids from the server 5000 at a time. So the very first request I get 0-5000, next request 5001-10000, then 10001-15000....

It seems that I should be using the search_after API to get the records but puzzled on how to retrieve the data.

Here is what I tried to do, but I feel that I am not understanding what I am doing and how can I make multiple requests..

var products = await elasticClient.SearchAsync<Product>(x =>  
    x.Source(s => s.Includes(se => se.Field(sef => sef.Id))) // all I need back is the "id" field
     .Sort(srt => srt.Ascending(p => p.Id)) // we can sort the ids
     .SearchAfter(5000, "get list of ids??"); // I have no idea what parameters to provide this method!
);

How can I use the .net library to loop over all available ids "5000" ids at a time?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Try this with pageNumber param:

var products = await elasticClient.SearchAsync<Product>(x =>  
    x.Source(s => s.Includes(se => se.Field(sef => sef.Id)))
    .From(5000*(pageNumber-1))
    .Size(5000)
    .Sort(srt => srt.Ascending(p => p.Id))
);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!